<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="跳转页面">
                <j-dict-select-tag
                :dictOptions="dictOptions"
                v-model="selectedOption"
                placeholder="请选择跳转页面"
                @change="handleChange"
              />
              </a-form-item>
            </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-button type="primary" @click="" icon="search">跳转</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('axcq540_ch_all')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <axcq540-ch-all-modal ref="modalForm" @ok="modalFormOk"></axcq540-ch-all-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import Axcq540ChAllModal from './modules/Axcq540ChAllModal'

  export default {
    name: 'Axcq540ChAllList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      Axcq540ChAllModal
    },
    data () {
      return {
        description: 'axcq540_ch_all管理页面',
        selectedOption:null,
        dictOptions:[{
          text:"选项一",
          value:"1"
        },{
          text:"选项二",
          value:"2"
        },{
          text:"选项三",
          value:"3"
        }],
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'年份',
            align:"center",
            dataIndex: 'year'
          },
          {
            title:'月份',
            align:"center",
            dataIndex: 'month'
          },
          {
            title:'成本分群',
            align:"center",
            dataIndex: 'costGroup'
          },
          {
            title:'成本分群说明',
            align:"center",
            dataIndex: 'costGroupDesc'
          },
          {
            title:'成本中心',
            align:"center",
            dataIndex: 'costCenter'
          },
          {
            title:'说明(简称)',
            align:"center",
            dataIndex: 'descShort'
          },
          {
            title:'委外商编码',
            align:"center",
            dataIndex: 'vendorCode'
          },
          {
            title:'委外商名称',
            align:"center",
            dataIndex: 'vendorName'
          },
          {
            title:'营运据点',
            align:"center",
            dataIndex: 'site'
          },
          {
            title:'说明(简称)',
            align:"center",
            dataIndex: 'siteDescShort'
          },
          {
            title:'在制单号',
            align:"center",
            dataIndex: 'wipOrderNo'
          },
          {
            title:'主件料号',
            align:"center",
            dataIndex: 'mainItemCode'
          },
          {
            title:'品名',
            align:"center",
            dataIndex: 'itemName'
          },
          {
            title:'规格',
            align:"center",
            dataIndex: 'spec'
          },
          {
            title:'主料产品特征',
            align:"center",
            dataIndex: 'mainItemFeature'
          },
          {
            title:'批号',
            align:"center",
            dataIndex: 'batchNo'
          },
          {
            title:'成本单位',
            align:"center",
            dataIndex: 'costUnit'
          },
          {
            title:'说明',
            align:"center",
            dataIndex: 'description'
          },
          {
            title:'成本域',
            align:"center",
            dataIndex: 'costDomain'
          },
          {
            title:'期初在制数量',
            align:"center",
            dataIndex: 'openingWipQty'
          },
          {
            title:'期初在制成本-材料',
            align:"center",
            dataIndex: 'openingMatCost'
          },
          {
            title:'期初在制成本-人工',
            align:"center",
            dataIndex: 'openingLaborCost'
          },
          {
            title:'期初在制成本-加工',
            align:"center",
            dataIndex: 'openingProcCost'
          },
          {
            title:'期初在制成本-制费一',
            align:"center",
            dataIndex: 'openingMfgCost1'
          },
          {
            title:'期初在制成本-制费二',
            align:"center",
            dataIndex: 'openingMfgCost2'
          },
          {
            title:'期初在制成本-制费三',
            align:"center",
            dataIndex: 'openingMfgCost3'
          },
          {
            title:'期初在制成本-制费四',
            align:"center",
            dataIndex: 'openingMfgCost4'
          },
          {
            title:'期初在制成本-制费五',
            align:"center",
            dataIndex: 'openingMfgCost5'
          },
          {
            title:'期初在制成本',
            align:"center",
            dataIndex: 'openingTotalCost'
          },
          {
            title:'本期在制投入数量',
            align:"center",
            dataIndex: 'currentInputQty'
          },
          {
            title:'本期在制投入成本-材料',
            align:"center",
            dataIndex: 'currentInputMat'
          },
          {
            title:'本期在制投入成本-人工',
            align:"center",
            dataIndex: 'currentInputLabor'
          },
          {
            title:'本期在制投入成本-加工',
            align:"center",
            dataIndex: 'currentInputProc'
          },
          {
            title:'本期在制投入成本-制费一',
            align:"center",
            dataIndex: 'currentInputMfg1'
          },
          {
            title:'本期在制投入成本-制费二',
            align:"center",
            dataIndex: 'currentInputMfg2'
          },
          {
            title:'本期在制投入成本-制费三',
            align:"center",
            dataIndex: 'currentInputMfg3'
          },
          {
            title:'本期在制投入成本-制费四',
            align:"center",
            dataIndex: 'currentInputMfg4'
          },
          {
            title:'本期在制投入成本-制费五',
            align:"center",
            dataIndex: 'currentInputMfg5'
          },
          {
            title:'本期在制投入成本',
            align:"center",
            dataIndex: 'currentInputTotal'
          },
          {
            title:'本期在制下阶投入成本-材料',
            align:"center",
            dataIndex: 'currentLowerInputMat'
          },
          {
            title:'本期在制下阶投入成本-人工',
            align:"center",
            dataIndex: 'currentLowerInputLabor'
          },
          {
            title:'本期在制下阶投入成本-加工',
            align:"center",
            dataIndex: 'currentLowerInputProc'
          },
          {
            title:'本期在制下阶投入成本-制费一',
            align:"center",
            dataIndex: 'currentLowerInputMfg1'
          },
          {
            title:'本期在制下阶投入成本-制费二',
            align:"center",
            dataIndex: 'currentLowerInputMfg2'
          },
          {
            title:'本期在制下阶投入成本-制费三',
            align:"center",
            dataIndex: 'currentLowerInputMfg3'
          },
          {
            title:'本期在制下阶投入成本-制费四',
            align:"center",
            dataIndex: 'currentLowerInputMfg4'
          },
          {
            title:'本期在制下阶投入成本-制费五',
            align:"center",
            dataIndex: 'currentLowerInputMfg5'
          },
          {
            title:'本期在制下阶投入成本',
            align:"center",
            dataIndex: 'currentLowerInputTotal'
          },
          {
            title:'本期在制转出数量',
            align:"center",
            dataIndex: 'currentOutputQty'
          },
          {
            title:'本期在制转出成本-材料',
            align:"center",
            dataIndex: 'currentOutputMat'
          },
          {
            title:'本期在制转出成本-人工',
            align:"center",
            dataIndex: 'currentOutputLabor'
          },
          {
            title:'本期在制转出成本-加工',
            align:"center",
            dataIndex: 'currentOutputProc'
          },
          {
            title:'本期在制转出成本-制费一',
            align:"center",
            dataIndex: 'currentOutputMfg1'
          },
          {
            title:'本期在制转出成本-制费二',
            align:"center",
            dataIndex: 'currentOutputMfg2'
          },
          {
            title:'本期在制转出成本-制费三',
            align:"center",
            dataIndex: 'currentOutputMfg3'
          },
          {
            title:'本期在制转出成本-制费四',
            align:"center",
            dataIndex: 'currentOutputMfg4'
          },
          {
            title:'本期在制转出成本-制费五',
            align:"center",
            dataIndex: 'currentOutputMfg5'
          },
          {
            title:'本期在制转出成本',
            align:"center",
            dataIndex: 'currentOutputTotal'
          },
          {
            title:'在制差异转出数量',
            align:"center",
            dataIndex: 'varianceOutputQty'
          },
          {
            title:'在制差异转出成本-材料',
            align:"center",
            dataIndex: 'varianceOutputMat'
          },
          {
            title:'在制差异转出成本-人工',
            align:"center",
            dataIndex: 'varianceOutputLabor'
          },
          {
            title:'在制差异转出成本-加工',
            align:"center",
            dataIndex: 'varianceOutputProc'
          },
          {
            title:'在制差异转出成本-制费一',
            align:"center",
            dataIndex: 'varianceOutputMfg1'
          },
          {
            title:'在制差异转出成本-制费二',
            align:"center",
            dataIndex: 'varianceOutputMfg2'
          },
          {
            title:'在制差异转出成本-制费三',
            align:"center",
            dataIndex: 'varianceOutputMfg3'
          },
          {
            title:'在制差异转出成本-制费四',
            align:"center",
            dataIndex: 'varianceOutputMfg4'
          },
          {
            title:'在制差异转出成本-制费五',
            align:"center",
            dataIndex: 'varianceOutputMfg5'
          },
          {
            title:'在制差异转出成本',
            align:"center",
            dataIndex: 'varianceOutputTotal'
          },
          {
            title:'期末在制数量',
            align:"center",
            dataIndex: 'closingWipQty'
          },
          {
            title:'期末在制成本-材料',
            align:"center",
            dataIndex: 'closingMatCost'
          },
          {
            title:'期末在制成本-人工',
            align:"center",
            dataIndex: 'closingLaborCost'
          },
          {
            title:'期末在制成本-加工',
            align:"center",
            dataIndex: 'closingProcCost'
          },
          {
            title:'期末在制成本-制费一',
            align:"center",
            dataIndex: 'closingMfgCost1'
          },
          {
            title:'期末在制成本-制费二',
            align:"center",
            dataIndex: 'closingMfgCost2'
          },
          {
            title:'期末在制成本-制费三',
            align:"center",
            dataIndex: 'closingMfgCost3'
          },
          {
            title:'期末在制成本-制费四',
            align:"center",
            dataIndex: 'closingMfgCost4'
          },
          {
            title:'期末在制成本-制费五',
            align:"center",
            dataIndex: 'closingMfgCost5'
          },
          {
            title:'期末在制成本',
            align:"center",
            dataIndex: 'closingTotalCost'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/ch/axcq540ChAll/list",
          delete: "/ch/axcq540ChAll/delete",
          deleteBatch: "/ch/axcq540ChAll/deleteBatch",
          exportXlsUrl: "/ch/axcq540ChAll/exportXls",
          importExcelUrl: "ch/axcq540ChAll/importExcel",
          reportPowerUrl: "/ch/reportPower/getReportByUserId",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      handleChange(value) {
      console.log('选中项：', value)
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'year',text:'年份',dictCode:''})
        fieldList.push({type:'string',value:'month',text:'月份',dictCode:''})
        fieldList.push({type:'string',value:'costGroup',text:'成本分群',dictCode:''})
        fieldList.push({type:'string',value:'costGroupDesc',text:'成本分群说明',dictCode:''})
        fieldList.push({type:'string',value:'costCenter',text:'成本中心',dictCode:''})
        fieldList.push({type:'string',value:'descShort',text:'说明(简称)',dictCode:''})
        fieldList.push({type:'string',value:'vendorCode',text:'委外商编码',dictCode:''})
        fieldList.push({type:'string',value:'vendorName',text:'委外商名称',dictCode:''})
        fieldList.push({type:'string',value:'site',text:'营运据点',dictCode:''})
        fieldList.push({type:'string',value:'siteDescShort',text:'说明(简称)',dictCode:''})
        fieldList.push({type:'string',value:'wipOrderNo',text:'在制单号',dictCode:''})
        fieldList.push({type:'string',value:'mainItemCode',text:'主件料号',dictCode:''})
        fieldList.push({type:'string',value:'itemName',text:'品名',dictCode:''})
        fieldList.push({type:'string',value:'spec',text:'规格',dictCode:''})
        fieldList.push({type:'string',value:'mainItemFeature',text:'主料产品特征',dictCode:''})
        fieldList.push({type:'string',value:'batchNo',text:'批号',dictCode:''})
        fieldList.push({type:'string',value:'costUnit',text:'成本单位',dictCode:''})
        fieldList.push({type:'string',value:'description',text:'说明',dictCode:''})
        fieldList.push({type:'string',value:'costDomain',text:'成本域',dictCode:''})
        fieldList.push({type:'string',value:'openingWipQty',text:'期初在制数量',dictCode:''})
        fieldList.push({type:'string',value:'openingMatCost',text:'期初在制成本-材料',dictCode:''})
        fieldList.push({type:'string',value:'openingLaborCost',text:'期初在制成本-人工',dictCode:''})
        fieldList.push({type:'string',value:'openingProcCost',text:'期初在制成本-加工',dictCode:''})
        fieldList.push({type:'string',value:'openingMfgCost1',text:'期初在制成本-制费一',dictCode:''})
        fieldList.push({type:'string',value:'openingMfgCost2',text:'期初在制成本-制费二',dictCode:''})
        fieldList.push({type:'string',value:'openingMfgCost3',text:'期初在制成本-制费三',dictCode:''})
        fieldList.push({type:'string',value:'openingMfgCost4',text:'期初在制成本-制费四',dictCode:''})
        fieldList.push({type:'string',value:'openingMfgCost5',text:'期初在制成本-制费五',dictCode:''})
        fieldList.push({type:'string',value:'openingTotalCost',text:'期初在制成本',dictCode:''})
        fieldList.push({type:'string',value:'currentInputQty',text:'本期在制投入数量',dictCode:''})
        fieldList.push({type:'string',value:'currentInputMat',text:'本期在制投入成本-材料',dictCode:''})
        fieldList.push({type:'string',value:'currentInputLabor',text:'本期在制投入成本-人工',dictCode:''})
        fieldList.push({type:'string',value:'currentInputProc',text:'本期在制投入成本-加工',dictCode:''})
        fieldList.push({type:'string',value:'currentInputMfg1',text:'本期在制投入成本-制费一',dictCode:''})
        fieldList.push({type:'string',value:'currentInputMfg2',text:'本期在制投入成本-制费二',dictCode:''})
        fieldList.push({type:'string',value:'currentInputMfg3',text:'本期在制投入成本-制费三',dictCode:''})
        fieldList.push({type:'string',value:'currentInputMfg4',text:'本期在制投入成本-制费四',dictCode:''})
        fieldList.push({type:'string',value:'currentInputMfg5',text:'本期在制投入成本-制费五',dictCode:''})
        fieldList.push({type:'string',value:'currentInputTotal',text:'本期在制投入成本',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputMat',text:'本期在制下阶投入成本-材料',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputLabor',text:'本期在制下阶投入成本-人工',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputProc',text:'本期在制下阶投入成本-加工',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputMfg1',text:'本期在制下阶投入成本-制费一',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputMfg2',text:'本期在制下阶投入成本-制费二',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputMfg3',text:'本期在制下阶投入成本-制费三',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputMfg4',text:'本期在制下阶投入成本-制费四',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputMfg5',text:'本期在制下阶投入成本-制费五',dictCode:''})
        fieldList.push({type:'string',value:'currentLowerInputTotal',text:'本期在制下阶投入成本',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputQty',text:'本期在制转出数量',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputMat',text:'本期在制转出成本-材料',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputLabor',text:'本期在制转出成本-人工',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputProc',text:'本期在制转出成本-加工',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputMfg1',text:'本期在制转出成本-制费一',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputMfg2',text:'本期在制转出成本-制费二',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputMfg3',text:'本期在制转出成本-制费三',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputMfg4',text:'本期在制转出成本-制费四',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputMfg5',text:'本期在制转出成本-制费五',dictCode:''})
        fieldList.push({type:'string',value:'currentOutputTotal',text:'本期在制转出成本',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputQty',text:'在制差异转出数量',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputMat',text:'在制差异转出成本-材料',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputLabor',text:'在制差异转出成本-人工',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputProc',text:'在制差异转出成本-加工',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputMfg1',text:'在制差异转出成本-制费一',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputMfg2',text:'在制差异转出成本-制费二',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputMfg3',text:'在制差异转出成本-制费三',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputMfg4',text:'在制差异转出成本-制费四',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputMfg5',text:'在制差异转出成本-制费五',dictCode:''})
        fieldList.push({type:'string',value:'varianceOutputTotal',text:'在制差异转出成本',dictCode:''})
        fieldList.push({type:'string',value:'closingWipQty',text:'期末在制数量',dictCode:''})
        fieldList.push({type:'string',value:'closingMatCost',text:'期末在制成本-材料',dictCode:''})
        fieldList.push({type:'string',value:'closingLaborCost',text:'期末在制成本-人工',dictCode:''})
        fieldList.push({type:'string',value:'closingProcCost',text:'期末在制成本-加工',dictCode:''})
        fieldList.push({type:'string',value:'closingMfgCost1',text:'期末在制成本-制费一',dictCode:''})
        fieldList.push({type:'string',value:'closingMfgCost2',text:'期末在制成本-制费二',dictCode:''})
        fieldList.push({type:'string',value:'closingMfgCost3',text:'期末在制成本-制费三',dictCode:''})
        fieldList.push({type:'string',value:'closingMfgCost4',text:'期末在制成本-制费四',dictCode:''})
        fieldList.push({type:'string',value:'closingMfgCost5',text:'期末在制成本-制费五',dictCode:''})
        fieldList.push({type:'string',value:'closingTotalCost',text:'期末在制成本',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>